<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 首页控制器
 */
class Index extends AdminBase
{
    
    /**
     * 首页方法
     */
    public function index()
    {
        
        // 获取首页数据
        $index_data = $this->logicAdminBase->getIndexData();
        
        $this->assign('info', $index_data);
        
        return $this->fetch('index');
    }

    public function get(){//获取手机号归属
        $mobile=$_GET['tel'];
        if (!preg_match("/^1[34578]\d{9}$/", $mobile)) {
            return '请输入正确手机号码！';
        }else{
            $phone_json = file_get_contents('http://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query={'.$mobile.'}&resource_id=6004&ie=utf8&oe=utf8&format=json');
            $phone_array = json_decode($phone_json,true);
            $phone_info = array();
            $phone_info['mobile'] = $mobile;
            $phone_info['type'] = $phone_array['data'][0]['type'];
            $phone_info['location'] = $phone_array['data'][0]['prov'].$phone_array['data'][0]['city'];
            dump($phone_array);
        }
    }
}
